package com.hdq.controller.admin;

import com.hdq.result.PageResult;
import com.hdq.result.Result;
import com.hdq.service.CouponService;
import com.hdq.service.SkusService;
import dto.CouponAddDTO;
import dto.CouponEditDTO;
import dto.SkusAddDTO;
import dto.SkusEditDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/coupon")
@Tag(name = "优惠卷管理")
public class CouponController {

    @Autowired
    private CouponService couponService;
    @GetMapping("/{page}")
    @Operation(summary = "分页查询优惠卷")
    public Result<PageResult> selectByPage(@PathVariable Integer page, @RequestParam Integer pageSize) {
        PageResult list= couponService.selectByPage(page,pageSize);
        return Result.success(list);
    }

    @PostMapping
    @Operation(summary = "新增优惠卷")
    public Result insert(@RequestBody CouponAddDTO couponAddDTO) {
        couponService.insert(couponAddDTO);
        return Result.success();
    }

    @DeleteMapping
    @Operation(summary = "删除优惠卷/批量删除")
    public Result delete(@RequestParam List<Long> ids) {
        couponService.delete(ids);
        return Result.success();
    }

    @PutMapping
    @Operation(summary = "更新优惠卷")
    public Result update(@RequestBody CouponEditDTO couponEditDTO) {
        couponService.update(couponEditDTO);
        return Result.success();
    }


}
